﻿using System;

namespace YanZhiwei.DotNet.Office11.Utilities
{

    public static class OfficeHelper
    {
        #region 参考：http://www.codeproject.com/Tips/701015/How-to-Check-Whether-Word-is-Installed-in-the-Syst
        /// <summary>
        /// 检查是否安装word
        /// </summary>
        /// <returns></returns>
        public static bool isWordInstalled()
        {
            return isApplicationInstalled("Word.Application");
        }
        /// <summary>
        /// 检查是否安装excel
        /// </summary>
        /// <returns></returns>
        public static bool isExcelInstalled()
        {
            return isApplicationInstalled("Excel.Application");
        }
        private static bool isApplicationInstalled(string applicationName)
        {
            Type _officeType = Type.GetTypeFromProgID(applicationName);
            return _officeType != null;
        }
        #endregion
    }
}
